<template>
  <!-- 筛选模块 -->
  <el-row class="head">
    <el-col :span="4">
      <el-button @click="drawerChange()" type="primary">新增产品</el-button>
    </el-col>
    <el-col :span="8">
      <div class="block" v-show="false">
        <span class="demonstration">日期时间：</span>
        <el-date-picker
          v-model="info.date"
          type="datetime"
          placeholder="日期和时间"
          format="YYYY/MM/DD hh:mm:ss"
          value-format="YYYY-MM-DD h:m:s a"
          @change="searchDate"
        />
      </div>
    </el-col>
    <!-- <el-col :span="6">
      <span class="demonstration">文章分类：</span>
      <el-select v-model="info.select" placeholder="请选择">
        <el-option
          v-for="item in sort"
          :key="item.id"
          :label="item.content"
          :value="item.id"
          @click="select(item.id)"
        >
        </el-option>
      </el-select>
    </el-col> -->
    <el-col :span="12" class="form-search">
      <el-input
        placeholder="产品名称"
        prefix-icon="el-icon-search"
        v-model="info.key"
        class="form-search-input"
      >
      </el-input>
      <el-button @click="searchKey" type="primary" style="margin-left: 20px"
        >搜索</el-button
      >
    </el-col>
  </el-row>
</template>

<script setup>
import { aticleSort } from '@/api/article.js'
import { reactive } from 'vue-demi'

const sort = ref([])

const info = reactive({
  date: '',
  select: '',
  key: ''
})

onMounted(() => {
  aticleSort().then((res) => {
    sort.value = res
  })
})

const emits = defineEmits([
  'drawerChangeEmits',
  'selectEmits',
  'searchKeyEmits',
  'searchDateEmits'
])
const drawerChange = () => {
  emits('drawerChangeEmits')
}

const select = (page) => {
  emits('selectEmits', page)
}

const searchDate = (page) => {
  emits('searchDateEmits', page)
}

const searchKey = () => {
  emits('searchKeyEmits', info.key)
}
</script>

<style scoped>
.form-search-input {
  text-align: right;
  width: 200px;
}
</style>
